// const { type, post } = require("jquery")

$(function () {
    // 登录验证

    $('#login').click(function () {
        const username = $('#username').val().trim()
        const password = $('#password').val().trim()
        if (!password || !username) {
            layer.alert('用户名和密码不能为空')
            return
        }
        // 登录接口
        $.post(
            'http://localhost:8080/api/v1/admin/user/login',
            { username, password },
            function (res) {
                console.log(res)
                if (res.code !== 200) {
                    layer.msg(res.msg)
                    return
                }
                localStorage.getItem('token', res.token)
                location.href = 'index.html'
            }
        )
    })



})